package highlighter.app;

import highlighter.ast.impl.Program;
import highlighter.parser.*;
import highlighter.visitor.IASTVisitor;
import highlighter.visitor.impl.PrettyPrintVisitor;


import java.io.FileNotFoundException;
import java.io.FileReader;

import java_cup.runtime.Symbol;

public class AppFactory {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		String inputFile = "input.txt";
		
		HighlighterLexer lexer = null;
		try {
			lexer = new HighlighterLexer(new FileReader(inputFile));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		
		HighlighterParser parser = new HighlighterParser(lexer);

		Symbol sym = null;
		try {
			sym = parser.parse();
		} catch (Exception e) {
			e.printStackTrace();
		}
		Program astNodeProgram = (Program) sym.value;

		// visitor - print AST
		IASTVisitor visitor = new PrettyPrintVisitor();
		visitor.visit(astNodeProgram);


	}

}
